package com.kevin.test.spring.ioc;

import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;

public class GroupBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
	@Override
	protected void doParse(Element element, BeanDefinitionBuilder builder) {
		String groupName = element.getAttribute("groupName");
		String id = element.getAttribute("id");
		
		if (StringUtils.hasText(groupName)) {
			builder.addPropertyValue("groupName", groupName);
		}
		if (StringUtils.hasText(id)) {
			builder.addPropertyValue("id", id);
		}
	}
	@Override
	protected Class<?> getBeanClass(Element element) {
		return Group.class;
	}

}
